/***************************************************************************
 创建者: 华磊
 开始时间: 2018.8.14
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2017.5.8 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *                                                                         *
 ***************************************************************************/
#ifndef REGINSTRUCTIONLOGIC_H
#define REGINSTRUCTIONLOGIC_H
#include "registerinstruction.h"
#include "programset.h"
#include "instructionEnum.h"
#include "robotio.h"
#include "regdata.h"
#include "mccontrollerthread.h"


class ProgramEngine;
/**
 * @brief The RegInstructionLogic class  指令逻辑处理类
 */
class RegInstructionLogic
{
public:
    RegInstructionLogic(int robotIdIn, ProgramSet* programSetIn, RobotIo* ioControllerIn
                        , ProgramEngine* programEngineIn, RegData *regDataIn, McControllerThread *programMcControllerIn);

public:
    /**
     * @brief startReg              获取reg指令后的操作
     * @param programNum            正在运行的program的Number
     * @param registerInstruct      RegisterInstruction对象
     * @return                      返回１表示运行到了最后一行
     */
    E_PROGRAM_LOOP_RESULT startReg(int programNum,RegisterInstruction registerInstruct);

    E_PROGRAM_LOOP_RESULT startPrReg(int programNum,const PrRegisterInstruction &prRegisterInstruction);
    E_PROGRAM_LOOP_RESULT startPlReg(int programNum,const PlRegisterInstruction &plRegisterInstruction);




private:
    E_PROGRAM_LOOP_RESULT startGlobalReg(int programNum,RegisterInstruction registerInstruct);

    /**
     * @brief addMsg  , 添加消息反馈
     * @param messageLevel
     * @param componentName
     * @param messageType
     * @param messageCode
     * @param robotId
     * @param parameter1
     * @param parameter2
     * @param parameter3
     * @param parameter4
     */
    void addMsg( int messageLevel,
                 std::string componentName,
                 std::string messageType,
                 int messageCode,
                 int robotId,
                 int parameter1 = 0,
                 int parameter2 = 0,
                 int parameter3 = 0,
                 int parameter4 = 0,
                 QString message= "");

private:
    int robotId;
    ProgramSet* programSet;
    RobotIo* ioController;
    ProgramEngine* programEngine;

    /**
     * @brief listData      存储寄存器指令　＝右边的所有字符的容器
     */
    QVector <RegConditionBlock> *listData;
    /**
     * @brief regData           寄存器数据
     */
    RegData *regData;

    /**
     * @brief programMcController       算法线程指针
     */
    McControllerThread *programMcController;
};

#endif // REGINSTRUCTIONLOGIC_H
